import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    list: [],
    status: "all",
  },
  getters: {
    num(state) {
      return state.list.filter((i) => i.status == false).length;
    },
    //筛选未完成的数量
  },
  mutations: {
    add(state, obj) {
      state.list.push(obj);
    },
    changeStatus(state, val) {
      state.status = val;
    },
    //把当前的全部 未完成 已完成的状态存下来
    del(state, i) {
      state.list.splice(i, 1);
    },
  },
  actions: {},
  modules: {},
});
